package com.bawei.mall.product.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bawei.mall.product.domain.MallProductShoppingCart;
import com.bawei.mall.product.domain.model.ShoppingCartModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName MallProductShoppingCartMapper
 * @Description 描述
 * @Author ZiZheng.Li
 * @Date 2024/7/5 17:18
 */
public interface MallProductShoppingCartMapper extends BaseMapper<MallProductShoppingCart> {
    @Select("SELECT cart.*,user.id as memberId, user.nick_name as memberNickName, product.price as price," +
            "product.name as productName, product.pic as productPic, product.sku_id as productSkuId," +
            "product.product_sn as productSn,product.sub_title as productSubTitle,brand.name as productBrand," +
            "FROM mall_product_shopping_cart cart " +
            "LEFT JOIN cus_user_info user ON cart.cus_user_id = user.id " +
            "LEFT JOIN mall_product_info product ON cart.product_id = product.id " +
            "LEFT JOIN mall_product_brand_info brand ON product.brand_id = brand.id " +
            "LEFT JOIN mall_product_sku_info sku ON product.sku_id = sku.id " +
            "WHERE cart.cus_user_id = #{userId}")
    MallProductShoppingCart getUserWithRoles(Long userId);

    List<ShoppingCartModel> queryList(@Param("userId") Long userId);
}
